package com.isunland.managesystem.ui;

import com.google.gson.Gson;
import com.isunland.managesystem.base.BaseNetworkDialogFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.CustomerDialog;
import com.isunland.managesystem.entity.CustomerMainOriginal;
import com.isunland.managesystem.entity.CustomerMainOriginal.rCustomerMain;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class CustomerDeliveryDialogFragment extends BaseNetworkDialogFragment {

  @Override public ArrayList<CustomerDialog> resolveResponse(String arg0) {
    ArrayList<CustomerDialog> list = new ArrayList<CustomerDialog>();

    try {
      CustomerMainOriginal customer = new Gson().fromJson(arg0, CustomerMainOriginal.class);

      List<rCustomerMain> messageDialogs = customer.getRows();
      if (messageDialogs == null || messageDialogs.size() == 0) {

        return null;
      }
      for (int i = 0; i < messageDialogs.size(); i++) {
        list.add(new CustomerDialog(messageDialogs.get(i).getCustomerName(),
            messageDialogs.get(i).getId()));
      }
      return list;
    } catch (Exception e) {

    }

    return list;
  }

  @Override public String getUrl() {

    return ApiConst.URL_CUSTOMER_LIST;
  }

  @Override public HashMap<String, String> getparameters() {
    HashMap<String, String> params = new HashMap<String, String>();
    return params;
  }
}
